package com.bishe.demo.modules.other.controller;

import com.bishe.demo.modules.common.entity.ResultEntity;
import com.bishe.demo.modules.common.entity.SearchBean;
import com.bishe.demo.modules.other.entity.Scenery;
import com.bishe.demo.modules.other.service.SceneryService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class SceneryController {
    @Autowired
    private SceneryService sceneryService;

    @PostMapping(value = "/scenery", consumes = "application/json")
    ResultEntity<Scenery> insertScenery(@RequestBody Scenery scenery) {
        return sceneryService.insertScenery(scenery);
    }

    @PutMapping(value = "/scenery", consumes = "application/json")
    ResultEntity<Scenery> updateScenery(@RequestBody Scenery scenery) {
        return sceneryService.updateScenery(scenery);
    }

    @DeleteMapping("/scenery/{sceneryId}")
    ResultEntity<Scenery> deleteSceneryBySceneryId(@PathVariable int sceneryId) {
        return sceneryService.deleteSceneryBySceneryId(sceneryId);
    }

    @GetMapping("/scenery/{sceneryId}")
    Scenery getSceneryBySceneryId(@PathVariable int sceneryId) {
        return sceneryService.getSceneryBySceneryId(sceneryId);
    }

    @PostMapping(value = "/scenery/v2", consumes = "application/json")
    PageInfo<Scenery> getSceneryBySearchBean(@RequestBody SearchBean searchBean) {
        return sceneryService.getSceneryBySearchBean(searchBean);
    }
}
